import request from "../request";
import { CommentListBO, Comment } from "./types";
// 获取播放凭证
const getPlayAuth = (id: string) => {
  return request({
    url: `/website/video/playAuth/${id}`,
    method: "get",
  });
};

// 评论
const comment = (query: Comment) => {
  return request({
    url: "/website-comment",
    method: "post",
    data: query,
  });
};

// 获取评论列表
const getCommentList = (query: any) => {
  return request({
    url: "/website-comment/treeselect",
    method: "get",
    params: query,
  });
};

// 获取所有子评论
const getChildCommentList = (query: any) => {
  return request({
    url: "/website-comment/page",
    method: "get",
    params: query,
  });
};

// 点赞
const like = (id: string) => {
  return request({
    url: `/website/video/like/${id}`,
    method: "post",
  });
};

// 收藏视频
const choseCollection = (query: any) => {
  return request({
    url: `/website/collect`,
    method: "post",
    data: query,
  });
};

// 获取相关视频列表
const getRelatedList = (query: any) => {
  return request({
    url: `/website/video/recommendedList/${query.videoId}`,
    method: "get",
    params: query,
  });
};

// 取消收藏按钮
const handleCancelChose = (query: any) => {
  return request({
    url: `/website/collect`,
    method: "delete",
    params: query,
  });
};

// 获取视频详情
const getVideoDetail = (id: string) => {
  return request({
    url: `/website/video/${id}`,
    method: "get",
  });
}

// 心跳包
const heartBeat = (query: any) => {
  return request({
    url: `/website/video/heartbeat`,
    method: "post",
    data:query
  });
}

export {
  getPlayAuth,
  comment,
  getCommentList,
  getChildCommentList,
  like,
  choseCollection,
  getRelatedList,
  handleCancelChose,
  getVideoDetail,
  heartBeat
};
